// 选房历史 - Hotel
import { get } from 'lodash';
import { DataTypes, UUIDV4 } from 'sequelize';
import { MySqlModel, getSequelize } from '../db';

class RoomHistory extends MySqlModel {

}

RoomHistory.init({
  id: {
    type: DataTypes.UUID, unique: 'id', allowNull: false, defaultValue: UUIDV4, validate: { isUUID: 4 }, primaryKey: true, comment: '主键'
  },
  hotel_id: {
    type: DataTypes.UUID, allowNull: false, validate: { isUUID: 4 }, comment: '主体'
  },
  openid: {
    type: DataTypes.STRING(50), allowNull: false, comment: '用户唯一标识'
  },
  confirm_number: {
    type: DataTypes.STRING(50), allowNull: false, comment: '确认号'
  },
  resv_name_id: {
    type: DataTypes.STRING(50), allowNull: false, comment: 'resv_name_id'
  },
  primary_confirm_number: {
    type: DataTypes.STRING(50), allowNull: false, comment: '主预订确认号'
  },
  primary_resv_name_id: {
    type: DataTypes.STRING(50), allowNull: false, comment: '主预订resv_name_id'
  },
  origin_room: {
    type: DataTypes.STRING(50), allowNull: true, comment: '原始房号'
  },
  room: {
    type: DataTypes.STRING(50), allowNull: false, comment: '分配房号'
  },
  business_date: {
    type: DataTypes.DATEONLY, allowNull: false, comment: '业务日期'
  },
  created_at: {
    type: DataTypes.DATE, allowNull: false, comment: '创建时间'
  },
  updated_at: {
    type: DataTypes.DATE, allowNull: false, comment: '更新时间'
  },
  version: {
    type: DataTypes.INTEGER, allowNull: false, defaultValue: 0, comment: '版本控制'
  }
}, {
  sequelize: getSequelize(),
  tableName: 'room_history',
  comment: '选房历史',
  indexes: [{ fields: ['hotel_id', 'openid'] }]
});

export default RoomHistory;
